package com.yh.concert.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.ruoyi.common.utils.StringUtils;
import java.util.List;
import java.util.Map;
import com.yh.concert.mapper.YhMerchartMapper;
import com.yh.concert.domain.YhMerchart;
import com.yh.concert.service.IYhMerchartService;

/**
 * 商家信息Service业务层处理
 *
 * @author yh
 * @date 2025-02-26
 */
@Service
public class YhMerchartServiceImpl extends ServiceImpl<YhMerchartMapper, YhMerchart> implements IYhMerchartService {

    @Autowired
    private YhMerchartMapper yhMerchartMapper;

    /**
     * 查询商家信息列表
     *
     * @param yhMerchart 商家信息
     * @return 商家信息
     */
    @Override
    public List<YhMerchart> selectYhMerchartList(YhMerchart yhMerchart)
    {
        List<YhMerchart> yhMerchartList = yhMerchartMapper.selectList(buildQueryWrapper(yhMerchart));
        return yhMerchartList;
    }


    private LambdaQueryWrapper<YhMerchart> buildQueryWrapper(YhMerchart query) {
        Map<String, Object> params = query.getParams();
        LambdaQueryWrapper<YhMerchart> lqw = Wrappers.lambdaQuery();
        lqw.eq(query.getUserId() != null, YhMerchart::getUserId, query.getUserId());
        lqw.like(StringUtils.isNotBlank(query.getMerchartName()), YhMerchart::getMerchartName, query.getMerchartName());
        lqw.eq(query.getStatus() != null, YhMerchart::getStatus, query.getStatus());
        lqw.orderByDesc(YhMerchart::getCreateTime);
        return lqw;
    }

}
